<template>
	<view class="tabs flexR">
		<view v-for="(item,i) in list" :key='i' class="tab" @click="handleTab(i)">
			<text>{{item.name}}</text>
			<view class="bar" :class="current===i?'active':''"></view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			list: {
				type: Array,
				default: () => {
					return []
				}
			},
			current: {
				type: Number,
				default: 0
			}
		},
		methods: {
			handleTab(i) {
				this.$emit('click', i)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tabs {
		justify-content: space-between;
		align-items: center;
		font-size: 18px;
		line-height: 50px;
		height: 50px;
		.tab {
			position: relative;
			text-align: center;
			width: 50%;

			.bar {
				height: 0;
				width: 0;
				background-color: $uni-bg-color;
				position: absolute;
				bottom: 0;
			}

			.active {
				height: 4rpx;
				width: 100%;
				background-color: $text-color-active;
				transition: all .2s;
			}
		}

		border-bottom: 1px solid #d4d4d4;
	}
</style>